<?php
	class StringCache {
		private $max, $keys, $values;
		
		function __construct($max) {
			$this -> keys = array();
			$this -> values = array();
			$this -> max = $max;
		}
		
		public function add($key, $value) {
			$this -> keys[] = $key;
			$this -> values[] = $value;
			
			while (count($this -> keys) > $this -> max) {
				array_shift($this -> keys);
				array_shift($this -> values);
			}
		}
		
		public function exists($key) {
			return ($this -> get($key)) ? true : false;
		}
		
		public function get($key) {
			$index = array_search($key, $this -> keys);
			if ($index === false) return false;
			return $this -> values[$index];
		}
	}
?>